export default {
  data() {
    return {
      // 默认的全局分享内容
      share: {
        title: '古蜀笔记',
        path: '/pages/index',    // 全局分享的路径，比如 首页
        // imageUrl: 'https://s3.dova.link:3001/test/20231225/c74c4f34e7bf48d3b56fb27c368e7180.jpg',    // 全局分享的图片(可本地可网络)
      }
    }
  },
  // 定义全局分享
  // 1.发送给朋友
  onShareAppMessage(res) {

    let obj = {
      title: this.share.title,
      path: this.share.path,
      // imageUrl: this.share.imageUrl,
    }

    if (res.from == "button") {
      let pageInfo = res.target.dataset.obj
      var pages = getCurrentPages() // 获取栈实例
      let currentPage = pages[pages.length - 1]['$page']['fullPath'] //当前页面路径(带参数)
      obj.title = pageInfo.name
      if (pageInfo.code) {
        obj.path = currentPage + '&code=' + pageInfo.code
      } else {
        obj.path = currentPage
      }

      obj.imageUrl = pageInfo.homePhoto
      console.log(pageInfo, '分享');
    }

    return obj
  },
  //2.分享到朋友圈
  onShareTimeline(res) {
    return {
      title: this.share.title,
      path: this.share.path,
      // imageUrl: this.share.imageUrl,
    }
  },
}